import { defineStore } from 'pinia'
import recruiterApi from '@/api/recruiter'
import { useUserStore, useAuthStore } from './'

export const useRecruiterStore = defineStore('recruiter', {
  state: () => ({
    recruiter: null,
  }),
  getters: {},
  actions: {
    async getRecruiter() {
      try {
        const userStore = useUserStore()
        const res = await recruiterApi.getRecruiter(userStore.user_id)
        this.recruiter = res.data
        useAuthStore().setHasName(this.recruiter.name!==null)
        return Promise.resolve(res.data)
      } catch (error) {
        return Promise.reject(error)
      }
    },
    //更新信息
    // updateSeeker(data) {
    //   console.log('t',data.name);
    //   this.seeker.name= data.name
    //   this.seeker.gender= data.gender
    //   this.seeker.birth_date= data.birth_date
    //   this.seeker.address_code= data.address_code
    //   this.seeker.phone_number= data.phone_number
    //   this.seeker.email= data.email
    //   this.seeker.identity= data.identity
    //   this.seeker.state= data.state
    //   this.seeker.introduction= data.introduction
    // },
    resetRecruiter() {
      this.$reset()
    },
  },
})
